<style>.content .main-content {border:none;}
.mgb10 {
    margin-top: 0px;
}
#betRecord tbody tr td .prizeNumber {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-direction: row;
    flex-direction: row;
    -ms-flex-pack: center;
    justify-content: center;
}

#betRecord tbody tr td .prizeNumber>div {
   display: flex;
    width: 20px;
    height: 20px;
    background-color: red;
    -ms-flex-align: center;
    align-items: center;
    -ms-flex-pack: center;
    justify-content: center;
    margin: 0 1px;
    color: #fff;
    font-size: 12px;
    border-radius: 10px;
}

#betRecord_wrapper{
	padding: 10px;
}

 .btn-default {
    color: #333 !important;
    background-color: #fff !important;
    border-color: #ccc;
}
.ivu-input{
	width:100px;
}

.btn-primary {
    color: #fff;
    background-color: #337ab7;
    padding: 4px 12px !important;
    margin-bottom: 5px !important;
    margin-left: 10px;
    border-color: #2e6da4;
}

.reset{
	margin-left:10px;
	display: inline-block;
    line-height: 30px;
    color: #fff ;
    height: 30px;
    padding: 0 15px;
    border-radius: 3px;
    font-size: 14px;
    margin-right: 10px;
    min-width: 55px;
    text-align: center;
    cursor: pointer;
    background: #2e4158;
    margin: 10px 0;
}
    
</style>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<section data-v-c2f0218a="" class="main-content subBetRecord view">
		<div data-v-b879b2dc="" class="userTitle mgb10">下级投注记录</div>
		<div data-v-b879b2dc="" class="userMain mgb10">
			<ul data-v-b879b2dc="" class="todayView mgb10"
				style="text-align: left; margin-left: 0px; padding: 0px;">
				<em data-v-b879b2dc="">账号：</em>
				<input data-v-b879b2dc="" type="text" placeholder="下级投注查询" class="userInput">&nbsp;
				<a data-v-b879b2dc="" class="submitBtn">搜索</a>
				<a data-v-b879b2dc="" class="reset">重置</a>
			</ul>
			<ul data-v-157ea3ee="" data-v-b879b2dc="" class="searchType">
				<li data-v-157ea3ee=""><span data-v-157ea3ee="">彩种：</span> 
				<ins data-v-157ea3ee="" class="selectIcon">
						<div data-v-157ea3ee="" class="title">
							<select data-v-157ea3ee="" class="userSelect">
							</select>
						</div>
						<em data-v-157ea3ee=""></em>
					</ins>
					</li>
				<li data-v-157ea3ee="" class="_time"><span data-v-157ea3ee="">时间：
						 <a data-v-157ea3ee="" class="userSearch time active">今天</a><a
						data-v-157ea3ee="" class="userSearch time ">昨天</a><a
						data-v-157ea3ee="" class="userSearch time ">七天</a> 
					<!-- 	<input type="text" id="date1" placeholder="开始时间" value="" lay-key="" class="ivu-input layer-date" readonly="readonly">
						<span style="margin: 0 10px;">至</span>
						<input type="text" id="date2" placeholder="结束时间" value="" lay-key="" class="ivu-input layer-date" readonly="readonly">
						<button class="btn btn-primary">确定</button> -->
				</span></li>
				<li data-v-157ea3ee="" class="_state"><span data-v-157ea3ee="">类型：
						<a data-v-157ea3ee="" class="userSearch time active">全部</a>
						<a data-v-157ea3ee="" class="userSearch time ">已中奖</a>
						<a data-v-157ea3ee="" class="userSearch time ">未中奖</a>
						<a data-v-157ea3ee="" class="userSearch time ">等待开奖</a>
				</span></li>
			</ul>
			<div >
				<table class="class-tableDataTable class-table-needClick display table table-striped table-bordered table-hover"  id="betRecord">
					<thead>
						<tr >
							<th class="hidden-td"></th>
							<th>账号</th>
							<th>彩种名称</th>
							<th>期号</th>
							<th>投注时间 </th>
							<th>投注金额</th>
							<th>中奖金额</th>
							<th>开奖号码</th>
							<th>奖金状态</th>
							<th>投注记录</th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
			<!-- <div data-v-b879b2dc="" class="page">
				
			</div> -->
			<div data-v-b879b2dc="" class="userTip mgt15">
					<p data-v-b879b2dc="">
						<i data-v-b879b2dc=""></i>温馨提示：投注明细最多只保留7天。
					</p>
				</div>
		</div>
</section>
<script type="text/javascript">
	/* layui.use('laydate', function() { //layui时间插件
		 laydate= layui.laydate;
		laydate.render({
			elem: '#date1'
		});
		laydate.render({
			elem: '#date2'
		});
	}); */
	
	$.ajax({
		url : "/datas/wholeLot.do",
		data : {},
		type : 'post',
		dataType : 'json',
		success : function(data) { 
			$(".userSelect").empty();
			$(".userSelect").append("<option data-v-157ea3ee='' value=''>全部彩种</option>");
			for(var i = 0;i < data.data.length;i++){
				$(".userSelect").append("<option data-v-157ea3ee='' value='"+data.data[i].cname+"'>"+data.data[i].gameNameInChinese+"</option>")
			}
		},
	});
	var startTime =GetDateStr(0);//开始时间
	var endTime=GetDateStr(0);//结束时间
	var cname="";//根据彩种名查询
	var state= "";
	function dataTable01(){
		var oTable=	$("#betRecord").DataTable({
				 "bProcessing" : false, 
				"bServerSide" : true,
				 "bPaginate" : true, 
				"sAjaxSource" : "/agencyCenter/xjcathecticRecord.do",
				"fnServerData" : retrieveData, 
				"destroy":true,
			       "bLengthChange": true,      
			      "bSort": false,
			      "bAutoWidth": false,
			       'aLengthMenu':[5], 
			       "searching": false,  
			       "pagingType": "simple_numbers",
			       "dom": "t<'tableinfo'i<'tableSearch'p>l>",  
			       
			       "language": {
			            "lengthMenu": "每页显示 _MENU_ 条记录",     
			             "zeroRecords": "没有检索到数据",     
			            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",     
			            "info": "没有数据",     
			            "oPaginate": {     
			                "sFirst": "首页",     
			                "sPrevious": "前一页",     
			                "sNext": "后一页",     
			                "sLast": "尾页"    
			          	},
			            "search":"",
			            "searchPlaceholder": "请输入关键字",
			            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
			            "infoEmpty":      "没有找到匹配的信息",
			         },  
			         "columnDefs": [{"defaultContent": "",
	                      "targets": "_all"}],
			         "columns": [
			        	 { "data": "id","className":" id-td hidden-td"}, 
			        	 { "data": "huiyuanzh", "className": "huiyuanzh-td" },
						 { "data": "cname1", "className": "cname1-td" },	
	                     { "data": "period", "className": "period-td" },
	                     { "data": "orderdate", "className": "orderdate-td"   },
	                     { "data": "acount", "className": "lottermoney-td"  },
	                     { "data": "goalmoney", "className": "goalmoney-td"  },
	                     { "data": "lotternum","className": "lotternum-td" },
	                     { "data": "state","className": "state-td" },
	                     { "data": null, "defaultContent": "<button class='btn btn-default'>查看详情</button>"},
	                 ],	
			});
		function retrieveData(sSource, aoData, fnCallback) {
			$.ajax({
				url : sSource,
				data : {
					"pageCount":aoData[0].value,
					"startIndex":aoData[3].value,
					"lineCount":aoData[4].value,
					"state":state,
					"xname":$(".userInput").val(),
					"cname":cname,
					"date1":startTime,
					"date2":endTime,
				},	
				type : 'post',
				dataType : 'json',
				async : false,
				success : function(result) { 
					var newJson = result.aaData;
					if(newJson=="" && $(".userInput").val()!=""){
						$(".userInput").val("");
						layer.alert("没有这个下级用户，请重新输入");
					}
					
					for(i=0;i<newJson.length;i++){
						var item=newJson[i];
						if(item.state==3){
							item.state="已中奖"
						}else if(item.state==2){
							item.state="未中奖"
						}else if(item.state==1){
							item.state="待中奖"
						}
						item.lottermoney+="元";
						item.goalmoney+="元";
						if(item.lotternum==undefined){
							item.lotternum="开奖中"
						}else{
							  var lotterNumber = item.lotternum.split(',');
								var html="<div class='prizeNumber'>";
								for(j=0;j<lotterNumber.length-1;j++){
									if(item.cname=="2fpk10" || item.cname=="bjpk10"  || item.cname=="xysm"  || item.cname=="xyft" || item.cname=="2fft"){
										html+="<div class='ball qiu"+Number(lotterNumber[j])+"'>"+lotterNumber[j]+"</div>"
									} else if(item.cname=="xg6hc" || item.cname=="5f6hc"){
										if(j==lotterNumber.length-2){
											html+="<div class='lhc' style='font-size:28px;font-weight:bold;color:black'>+</div>";
										}
										html+="<div class='lhc'><div class='ball xg"+Number(lotterNumber[j])+"'>"+lotterNumber[j]+"</div>"
									} else if(item.cname=="ahk3" || item.cname=="gxk3" || item.cname=="jsk3" || item.cname=="3fk3" || item.cname=="bjk3" || item.cname=="2fk3"){
										html+="<div class='ball sz"+lotterNumber[j]+"'></div>"
									}else{
										html+="<div class='ball qiu8'>"+lotterNumber[j]+"</div>"
									} 
								}
								html+="</div>";
								item.lotternum=html; 	
						}
					}
	        		 result.aaData=newJson;
					fnCallback(result);
				},
				error : function(msg) {
				}
			});
		};
	}
	dataTable01();
	
	/* 查看投注详情 */
	$("#betRecord").on("click",".btn-default",function(){
		$("#addAndEditModal").modal("show")
		var body = $(".modal-body");
		var id = $(this).parent().siblings().parent().find(".id-td").text()
		$.ajax({
				type: "post",
				url: "/orders/touzhuRecord.do",
				"data": {
					'id': id
				},
				success: function(data) {
					var datas = data.data
					var body = $(".modal-body")
					body.empty()
					var awardNumber = datas['lotternum']
					if(awardNumber == null || awardNumber == "") {
						awardNumber = "待开奖"
					}
					body.append("<p><span class='backbet'>投注期号：</span><input value='" + datas['period'] + "'class='form-control backCor' id='input-i-name' readonly /></p><p><span class='backbet'>开奖号码：</span><input value='" + awardNumber + "' class='form-control backCor' id='input-i-nicheng' readonly /></p>")
					for(i = 1; i < 41; i++) {
						if(datas['str' + i] != '' && datas['str' + i] != null) {
							body.append("<p><span>投注玩法：</span><input value='" + datas['cplay' + i] + "' class='form-control' readonly /></p><p><span>投注号码：</span><input value='" + datas['str' + i] + "' class='form-control' readonly /></p>")
						}
					}
				}
			});
	})
	
	/* 彩种名查询 */
	$(".userSelect").change(function(){
		cname=$(".userSelect").val();
		dataTable01();
	});
	
	/* 时间查询 */
	$("._time a").on("click",function(){
		$(this).addClass("active");
		$(this).siblings().removeClass("active");
		var index=$(this).index();
		if(index==0){
			startTime =GetDateStr(0)
		}else if(index==1){
			startTime =GetDateStr(1)
		}else if(index==2){
			startTime =GetDateStr(7)
		}
		dataTable01();
	});
	
	/* $("._time .btn-primary").on("click",function(){
		if($("#date1").val()=="" || $("#date2").val()=="" ){
			return;
		}
		startTime = $("#date1").val();
		endTime= $("#date2").val();
		dataTable01();
	}) */
	
	/* 开奖状态切换 */
	$("._state a").on("click",function(){
		$("._state a").removeClass("active");
		$(this).addClass("active");
		var active =  $(this).text();
		if(active == '全部'){
			state = "";
		}else if(active == '已中奖'){
			state = 3;
		}else if(active == '等待开奖'){
			state = 1;
		}else if(active == '未中奖'){
			state = 2;
		}
		dataTable01();
	})
	
	
	/* 查询下级账号投注记录 */
	$(".submitBtn").on("click",function(){//dataTable搜索
		dataTable01();
	})
	
	/* 重置下级账号投注记录 */
	$(".reset").on("click",function(){//dataTable搜索
		$(".userInput").val("");
		startTime =GetDateStr(0);//开始时间
		cname="";//根据彩种名查询
		state= "";
		$("._state a").removeClass("active");
		$("._state a").eq(0).addClass("active");
		$("._time a").removeClass("active");
		$("._time a").eq(0).addClass("active");
		$(".userSelect").val("");
		dataTable01();
	})
</script>
